package obecto.transition
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;

	[Event(name="enter", type="flash.events.Event")]
	[Event(name="leave", type="flash.events.Event")]
	public class State extends EventDispatcher
	{
		[Bindable]
		public var name : String;

		protected var _active : Boolean = false;
		
		[Bindable("enter")]
		[Bindable("leave")]
		public function get active() : Boolean
		{
			return _active;
		}
		
		public function State(target:IEventDispatcher=null)
		{
			super(target);
		}
		
		public function enter() : void
		{
			if(_active == false)
			{
				_active = true;
				dispatchEvent(new Event("enter"));
			}
		}
		
		public function leave() : void
		{
			if(_active == true)
			{
				_active = false;
				dispatchEvent(new Event("leave"));
			}
		}
	}
}